package com.wechat.pay.api.vo;

import lombok.Data;

import java.io.Serializable;

/**
 * 结果集
 */
@Data
public class Result implements Serializable {

    public static final int OK_CODE = 200;
    private static final String OK_MSG = "成功";
    public static final int ERROR_CODE = 500;
    private static final String ERROR_MSG = "操作失败";

    /**
     * 响应业务状态
     */
    private Integer status;

    /**
     * 响应消息
     */
    private String msg;

    /**
     * 响应中的数据
     */
    private Object data;

    public Result(Integer status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public static Result ok() {
        return new Result(OK_CODE, OK_MSG, null);
    }

    public static Result ok(Object data) {
        return new Result(OK_CODE, OK_MSG, data);
    }

    public static Result error() {
        return new Result(ERROR_CODE, ERROR_MSG, null);
    }

    public static Result error(String msg) {
        return new Result(ERROR_CODE, msg, null);
    }

    public static Result error(Integer status, String msg) {
        return new Result(status, msg, null);
    }

    public static Result error(Integer status, String msg, Object data) {
        return new Result(status, msg, data);
    }

    private static final long serialVersionUID = -1457142805710723836L;
}
